package com.loongtech.bi.entity.system;

import com.loongtech.core.gen.GenInnerK;
import com.loongtech.core.jpa.entity.EntityIntAutoWithoutVersion;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.util.Date;

@Entity
@Table(name = "system_user", indexes = { @Index(name = "system_user_index_username", unique = true, columnList = "username") })
@GenInnerK
public class EntitySysUser extends EntityIntAutoWithoutVersion {
	private static final long serialVersionUID = 1L;
	@Column(columnDefinition = "varchar(255) NOT NULL default ''")
	private String username;
	@Column(columnDefinition = "varchar(255) NOT NULL default ''")
	private String password;
	@Column(columnDefinition = "varchar(255)")
	private String department;
	@Column(columnDefinition = "varchar(255) default ''")
	private String description;
	@Column(columnDefinition = "bit(1)", nullable = false)
	private boolean isAdmin;
	private Date registerTime = new Date();
	@Column(columnDefinition="varchar(255)   default ''")
	private String sign;

    private int version = 1;			//乐观锁

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Date getRegisterTime() {
		return registerTime;
	}

	public void setRegisterTime(Date registerTime) {
		this.registerTime = registerTime;
	}

	public boolean getIsAdmin() {
		return isAdmin;
	}

	public void setIsAdmin(boolean isAdmin) {
		this.isAdmin = isAdmin;
	}

	@Override
	public String toString() {
		return "EntitySysUser [username=" + username + ", password=" + password + ", department=" + department + ", description=" + description + ", isAdmin=" + isAdmin + ", registerTime=" + registerTime + "]";
	}

	public static class K {
		public static final String username = "username";
		public static final String password = "password";
		public static final String department = "department";
		public static final String description = "description";
		public static final String isAdmin = "isAdmin";
		public static final String registerTime = "registerTime";
		public static final String id = "id";
		public static final String version = "version";

		// username, password, department, description, isAdmin, registerTime,
		// id, version,
		public static java.util.List<String> toList() {
			java.util.List<String> list = new java.util.ArrayList<>();
			list.add(username);
			list.add(password);
			list.add(department);
			list.add(description);
			list.add(isAdmin);
			list.add(registerTime);
			list.add(id);
			list.add(version);
			return list;
		}
	}
}